﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Bootstrap.MVC.Common;
using Bootstrap.MVC.Utils;

namespace Bootstrap.MVC.Widgets
{
    public class ButtonBuilder : WidgetBuilderBase<IButtonModel, 
                                           ButtonBuilder, 
                                           ButtonHtmlGenerator,
                                           ButtonScriptGenerator>
    {
        public ButtonBuilder( IButtonModel model,
                             ButtonHtmlGenerator htmlGenerator,
                             ButtonScriptGenerator scriptGenerator )
            : base(model, htmlGenerator, scriptGenerator) { }


        public ButtonBuilder(IButtonModel model) : base(model) { }


        #region Public Methods
        public ButtonBuilder Size(ButtonSize size)
        {
            Guard.IsNotNull(size, "size");
            Model.Size = size;
            return this;
        }

        public ButtonBuilder Block(bool block= true)
        {
            Model.Block = block;
            return this;
        }

    
        public ButtonBuilder Icon(string icon,IconColors color = IconColors.Black, LeftOrRight position = LeftOrRight.Left)
        {
            Guard.IsNotNullOrEmpty(icon, "icon");

            Model.Icon = icon;
            Model.IconColor = color;
            Model.IconPosition = position;
            return this;
        }

        public ButtonBuilder Skin(Skins skin)
        {
            Model.Skin = skin;
            return this;
        }

        public ButtonBuilder ClientEvents(Action<ClientEventFactoryBase> eventAction)
        {
            Guard.IsNotNull(eventAction, "eventAction");

            var eventFactory = new ClientEventFactoryBase(Model);
            eventAction(eventFactory);

            return this;
        }

        #endregion Public Methods


    }
}
